﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PracticeEveryday
{
    internal class _250417
    {
        static void Main1(string[] args)
        {
            byte[] res = new byte[] { 0xCC, 0x00, 0xde, 0x97 };
            ushort value = (ushort)((res[3] << 8) | res[2]);
            double temp = ((double)value / 65536 * 3 - 1.5) / 0.0046 + 25;
            /*double step1 = value / 65536;
            double step2 = step1 * 3;
            double step3 = step2 - 1.5;
            double step4 = step3 / 0.0046;
            double step5 = step4 + 25;*/
            Console.WriteLine(temp);


            StringBuilder sb = new StringBuilder();
            string[] slotNames = new string[] {"Slot1","Slot2","Slot3" };
            foreach (string slotName in slotNames) 
            {
                var slot = int.Parse(slotName.Replace("Slot",""));
                sb.Append(slot);
                Console.WriteLine(slot);
            }
            Console.WriteLine(sb);
        }
    }
}
//4种单例模式学习
namespace PracticeEveryday
{

    public class Singleton
    {
        //1.懒汉式单例模式
        //使用lazy<T>来实现单例模式，确保线程安全和延迟加载
        //private static readonly Lazy<FilterLogger> instance = new Lazy<FilterLogger>(() => new FilterLogger());
        //private FilterLogger()
        //{
        //    //私有构造函数，防止外部实例化
        //}
        ////公共方法，返回单例实例
        //public static FilterLogger Instance => instance.Value;
        //{
        //    get
        //    {
        //        return instance.Value;
        //    }
        //}

        //2.饿汉式单例模式
        //在类加载时就创建实例，确保线程安全
        //private static readonly FilterLogger instance = new FilterLogger();
        //private FilterLogger()
        //{
        //    //私有构造函数，防止外部实例化
        //}
        //公共方法，返回单例实例
        //public static FilterLogger Instance => instance;
        //{
        //    get
        //    {
        //        return instance;
        //    }
        //}
        //3.双重检查锁定单例模式
        //private static FilterLogger? instance;
        //private static readonly object lockObj = new object();
        //private FilterLogger()
        //{

        //}
        //public static FilterLogger Instance
        //{
        //    get
        //    {
        //        //双重检查锁定
        //        if (instance == null)
        //        {
        //            lock (lockObj)
        //            {
        //                if (instance == null)
        //                {
        //                    instance = new FilterLogger();
        //                }
        //            }
        //        }
        //        return instance;
        //    }
        //}
        //4.静态只读属性单例模式
        //private static readonly FilterLogger instance = new FilterLogger();
        //private FilterLogger()
        //{

        //}
        //public static FilterLogger Instance
        //{
        //    get
        //    {
        //        return instance;
        //    }
        //}
        //static FilterLogger()
        //{
        //    //静态构造函数，确保在类加载时执行
        //    //可以在这里进行一些静态初始化操作
        //}
    }
    

}
